import { request } from '@/utils/request';

export interface Statistics {
  totalMedicinals: number;
  totalOrders: number;
  totalUsers: number;
  totalArticles: number;
}

export interface ChartData {
  dates: string[];
  counts: number[];
}

export interface RecognizeData {
  success: number;
  fail: number;
}

export interface ArticleStats {
  views: number[];
  likes: number[];
  collects: number[];
  dates: string[];
}

// 获取统计数据
export const getStatistics = () => {
  return request.get({
    url: '/dashboard/statistics',
  });
};

// 获取订单趋势
export const getOrderTrend = (startDate: string, endDate: string) => {
  return request.get({
    url: '/dashboard/order/trend',
    params: { startDate, endDate },
  });
};

// 获取用户活跃度
export const getUserActivity = (startDate: string, endDate: string) => {
  return request.get({
    url: '/dashboard/user/activity',
    params: { startDate, endDate },
  });
};

// 获取识别记录统计
export const getRecognizeStats = () => {
  return request.get({
    url: '/dashboard/recognize/stats',
  });
};

// 获取文章统计数据
export const getArticleStats = (timeRange: 'week' | 'month' | 'year') => {
  return request.get({
    url: '/dashboard/article/stats',
    params: { timeRange },
  });
};
